import { rest } from 'msw';
import { res } from './res';

// Define handlers that catch the corresponding requests and returns the mock data.
export const handlers = [
	rest.post('/v7/login', (request, response, ctx) => {
		return res(
			ctx.status(200),
			ctx.json({ loginName: 'admin', password: '123456' })
		);
	}),
	rest.get('/v7/logout', (request, response, ctx) => {
		return res(
			ctx.status(200),
			ctx.json({ loginName: 'admin', password: '123456' })
		);
	}),
	rest.get('/appdata', (request, response, ctx) => {
        const appdata = {
            accountexpired: "true",
            appmenu: [],
            context: {
                srfdcid: "preview", 
                srforgname: "HP", 
                srfusername: "机构管理员", 
                srfusercode: "ADMIN"
            },
            dynamodeltag: "0de0737f18e17e24784e7d5db87d735f",
            enablepermissionvalid: false,
            expireddate: "2023-01-12 16:01:53",
            expirein: 6622,
            mqtttopic: "/s06202b87153d246b5acbf8ed52301f6e/eaa864c08790ab9ee8d6e422062edcaf8",
            unires: [],
            version: "8.1.0.261"
        }
		return res(ctx.status(200), ctx.json({ ...appdata }));
	}),
];
